package com.example.mediatorpattern.entity;

/**
 * @author ash
 * @description
 * @create 2023/2/23  21:44:37
 * @className ConcreteMediator
 * @verson 1.0.0
 */
public class ConcreteMediator extends Mediator{

    private ConcreteColleague1 concreteColleague1;
    private ConcreteColleague2 concreteColleague2;

    public void setConcreteColleague1(ConcreteColleague1 concreteColleague1) {
        this.concreteColleague1 = concreteColleague1;
    }

    public void setConcreteColleague2(ConcreteColleague2 concreteColleague2) {
        this.concreteColleague2 = concreteColleague2;
    }

    @Override
    public void send(String message, Colleague colleague) {
        if (concreteColleague1 == colleague){
            concreteColleague2.notifyMessage(message);
        }else {
            concreteColleague1.notifyMessage(message);
        }
    }
}
